//
//  WHBaseTableTestVC.m
//  WHPersonalData
//
//  Created by shengmeng chen on 2022/6/24.
//  Copyright © 2022 mac. All rights reserved.
//

#import "WHBaseTableTestVC.h"
#import "WHBaseTableViewTestCell.h"
#import "SDAutoLayout.h"

@interface WHBaseTableTestVC ()

@end

@implementation WHBaseTableTestVC
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"测试实验";
    
}

#pragma mark - loadDatas
- (void)loadDatas{
    [super loadDatas];
    //发起网络请求 - 通过Model层，然后通过block回调给控制器，控制器刷新表格数据源
//    [WHBaseTableDatas fetchDatasSuccessBlock:^(NSArray *array) {
//        self.datas =[NSMutableArray arrayWithArray:array];
//    }];
}
#pragma mark - setupUI
- (void)setupUI{
    [super setupUI];
    //一个简单的super setupUI = createTableView
}
-(void)loadMoreDatas
{
    [super loadMoreDatas];
}


#pragma mark - <tableViewDelegate>
- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   
    WHBaseTableViewTestCell *cell = [WHBaseTableViewTestCell
                                     createReuseIdentifier:@"WHBaseTableCellID" WithTableView:tableView];
    cell.wHBasseCelTestModel = self.datas[indexPath.row];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView
 heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    return [self.tableView cellHeightForIndexPath:indexPath model:self.datas[indexPath.row] keyPath:@"wHBasseCelTestModel" cellClass:[WHBaseTableViewTestCell class] contentViewWidth:ScreenW];
}

-(void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.datas removeObjectAtIndex:indexPath.row];
    [self.tableView reloadData];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    DebugLog(@"tableView = %ld",(long)indexPath.row);
}
-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
    [self.view endEditing:YES];
}

#pragma mark - <searchViewDelegate>
-(void)searchTileViewTextFieldDidChange:(NSString *)textFieldString
{
    
}
-(void)searchTileViewSearchButtonClickSearchString:(NSString *)searchString
{
}

@end
